package com.wangrui.client.grid;

import java.util.List;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.RecordList;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.wangrui.client.GreetingService;
import com.wangrui.client.GreetingServiceAsync;
import com.wangrui.client.data.BeanSipfa01DTO;
import com.wangrui.client.data.BeanSipfa04DTO;
import com.wangrui.client.record.Sipfa01Record;
import com.wangrui.client.record.Sipfa04Record;

public class Sipfa04Grid extends ListGrid{
	
	public Sipfa04Grid(){
		
		setWidth100();   
        setHeight100();   
        setShowAllRecords(true);
        setAlign(Alignment.CENTER);
        setAutoFitAllText(getTitleField());
        
       ListGridField ocdateField = new ListGridField("OC_DATE", "日期");   
       ListGridField zqgsdmField = new ListGridField("ZQGSDM", "证券公司代码");   
       ListGridField yybnbdmField = new ListGridField("YYBNBDM", "营业部内部代码");   
       ListGridField khdmField = new ListGridField("KHDM", "客户代码");
       ListGridField khkhrqField = new ListGridField("KHKHRQ", "客户开户日期");   
       ListGridField khzxrqField = new ListGridField("KHZXRQ", "KHZXRQ");   
       ListGridField khmcField = new ListGridField("KHMC", "客户名称");   
       ListGridField khlxField = new ListGridField("KHLX", "客户类型"); 
       ListGridField khztField = new ListGridField("KHZT", "KHZT");   
       ListGridField zjlx1Field = new ListGridField("ZJLX1", "证件类型");   
       ListGridField zjhm1Field = new ListGridField("ZJHM1", "ZJHM1");
       ListGridField zjyxjzr1Field = new ListGridField("ZJYXJZR1", "ZJYXJZR1");   
       ListGridField zjlx2Field = new ListGridField("ZJLX2", "ZJLX2");   
       ListGridField zjhm2Field = new ListGridField("ZJHM2", "ZJHM2");   
       ListGridField zjyxjzr2Field = new ListGridField("ZJYXJZR2", "ZJYXJZR2"); 
       ListGridField khgjField = new ListGridField("KHGJ", "KHGJ");   
       ListGridField khxlField = new ListGridField("KHXL", "KHXL");   
       ListGridField khzyField = new ListGridField("KHZY", "KHZY");
       ListGridField frdbField = new ListGridField("FRDB", "FRDB");   
       ListGridField frdbzjhmField = new ListGridField("FRDBZJHM", "FRDBZJHM");   
       ListGridField jbrField = new ListGridField("JBR", "JBR");   
       ListGridField jbrzjhmField = new ListGridField("JBRZJHM", "JBRZJHM"); 
       ListGridField zcdzField = new ListGridField("ZCDZ", "ZCDZ");   
       ListGridField lxdzField = new ListGridField("LXDZ", "LXDZ");   
       ListGridField yzbmField = new ListGridField("YZBM", "YZBM");
       ListGridField lxdmField = new ListGridField("LXDH", "LXDH");   
       ListGridField sjhmField = new ListGridField("SJHM", "SJHM");   
       ListGridField dzyxField = new ListGridField("DZYX", "DZYX");   
       ListGridField cgmsField = new ListGridField("CGMS", "CGMS"); 
       ListGridField sjrqField = new ListGridField("SJRQ", "数据日期"); 
       
       setFields(ocdateField,zqgsdmField,yybnbdmField,khdmField,khkhrqField,khzxrqField,khmcField,khlxField,khztField,zjlx1Field,
    		   zjhm1Field,zjyxjzr1Field,zjlx2Field,zjhm2Field,zjyxjzr2Field,khgjField,khxlField,khzyField,frdbField,frdbzjhmField,
    		   jbrField,jbrzjhmField,zcdzField,lxdzField,yzbmField,lxdmField,sjhmField,dzyxField,cgmsField,sjrqField);
       
       setCanResizeFields(true);   
       
       GreetingServiceAsync getSipfa04Service = GreetingService.Util.getInstance();
       
       AsyncCallback cb_getSipfa04 = new AsyncCallback(){

			public void onFailure(Throwable caught) {}

			public void onSuccess(Object reuslt) {

			List data = (List)reuslt;
			 BeanSipfa04DTO[] array = new BeanSipfa04DTO[data.size()];
			// ListGridRecord[] sipfa01list = new ListGridRecord[data.size ()];
			 RecordList sipfa04list = new RecordList();
			   for (int i = 0; i < data.size(); i++) {

                   array[i] = (BeanSipfa04DTO) data.get(i);
                   
                   Sipfa04Record sipfa04Record = new Sipfa04Record(array[i].OC_DATE,array[i].ZQGSDM,array[i].YYBNBDM,array[i].KHDM,array[i].KHKHRQ,array[i].KHZXRQ,array[i].KHMC,array[i].KHLX,array[i].KHZT,array[i].ZJLX1,
            			array[i].ZJHM1,array[i].ZJYXJZR1,array[i].ZJLX2,array[i].ZJHM2,array[i].ZJYXJZR2,
            			array[i].KHGJ,array[i].KHXL,array[i].KHZY,array[i].FRDB,array[i].FRDBZJHM,array[i].JBR,
            			array[i].JBRZJHM,array[i].ZCDZ,array[i].LXDZ,array[i].YZBM,array[i].LXDH,array[i].SJHM,
            			array[i].DZYX,array[i].CGMS,array[i].SJRQ);
                  
                   sipfa04list.add(sipfa04Record);
                   
                 
                   System.out.println("打印返回的数据A04："+array[i].KHDM);               }
			
			
			setData(sipfa04list);
			
			
			
			
		//setData(getObj(reuslt));
		}
   	
       };getSipfa04Service.getSipfa04(cb_getSipfa04);
	}

}
